<template>
	<view class="pages">
		<view>
			<view class="content">
				<view>
					<view class="matchList">
						
						<view class="matchItem"  v-for="(item, index) in list" :key="index">
							<view class="name">{{item.dataName}}</view>
							<view class="flex">
								<view class="leftImg">
									
									<image mode="aspectFit" :src="item.dataImg"></image>
								</view>		
								<view class="rightWen">
									<view class="time" >{{item.dataDetail}}</view>
									<view class="feeBtn" @click="getFee(item.dataNum)">领取门票</view>
								</view>
							</view>
				
						</view>
					
						<view class="nodata" v-if="list.length==0">
							<image mode="aspectFit" src="/static/nodata.png"></image>
						</view>
					</view>
				</view>
			</view>
		</view>
		<uni-popup ref="inputDialog" type="dialog"  :mask-click="false">
			<view class="box">
				<text class="cuowu" @click="closePopup">×</text>
				<view class="title">请选择领取数量</view>
				 <view class="update-count">
				 					<view class="reduce" @click="changeCount(1)">
				 					   -
				 					</view>
				 					<view class="cart-count">
				 						{{num}}
				 					</view>
				 					<view class="reduce" @click="changeCount(2)">
				 						+
				 					</view>
				 </view>
				 <view class="btn" @click="confirmGet">确认领取</view>
			</view>
		    
		</uni-popup>
		<uni-popup ref="popupSuccess" type="message">
			<uni-popup-message :type="type" :message="title" :duration="2000"></uni-popup-message>
		</uni-popup>
	</view>
</template>

<script>
		import {showbaseinfolistbydetailkey,cardinfocreatesave} from "../../common/api.js"
	export default {
		data() {
			return {
				list:[{
					name:'无锡大满贯单刀赴会厚度',
					coverUrl:'/static/bg.png',
					type:'0',
					progressStatusCode:'3',
					signEndTime:'2024-12-30 11:00',
					beginTime:'2024-12-30 11:00',
					endTime:'2024-12-30 11:00',
				}
				],
				currUser:{},
				item:'',
				num:1,
				title:'成功提示',
				type:"success"
			}
		},
		created(){
			this.currUser = uni.getStorageSync('currUser')
			showbaseinfolistbydetailkey({dataType:'saishi' }).then(res=>{
				this.list=res.extend.list
			})
		},
		methods: {
			closePopup(){
				this.num=1
				this.item=''
				this.$refs.inputDialog.close()
			},
			changeCount(type){
				if(type==1){
					if(this.num>1){
						this.num--
					}
					
				}else{
					if(this.num<10){
					this.num++
					}
				}
				
			},
			getFee(item){
				console.log('-----',item)
				this.item=item
				this.$refs.inputDialog.open()
				// cardinfocreatesave({}).then(res=>{
					
				// })
			},
			confirmGet(){
				let form={
					userid:this.currUser.userid,
					saishiid:this.item,
					lingqunum:this.num,
				}
				cardinfocreatesave(form).then(res=>{
					if(res.code==100){
						 this.$refs.inputDialog.close()
						this.type="success"
						this.title=res.extend.MSG
						
							this.$refs.popupSuccess.open()
						
					}else{
						 this.$refs.inputDialog.close()
						this.type="error"
						this.title=res.extend.MSG
						console.log(this.title)
							this.$refs.popupSuccess.open()
					}
				  this.num=1
				  this.item=''
				 
				}).catch(err=>{
					 this.$refs.inputDialog.close()
					this.type="error"
					this.title=err.data.extend.MSG
						this.$refs.popupSuccess.open()
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.feeBtn{
	background:#ea6011;
	color:#fff;
	border-radius:5px;
	font-size:12px;
	line-height:20px;
	text-align:center;
	margin-top:15px;
}
.box{
	position: relative;
	text-align:center;
	background:#fff;
	padding:80rpx;
	.cuowu{
		position: absolute;
		right:30rpx;
		top:30rpx;
		font-size:40rpx;
	}
	.title{
		font-weight: bold;
		margin-bottom:20px;
	}
	.btn{
		text-decoration: underline;
	}
}
	.update-count{
		margin-bottom:10px;
		display:flex;
		justify-content:center;
		align-items:center;
		font-size:14px;
		background:#ea6011;
		color:#fff;
		height:60rpx;
		line-height:60rpx;
		.cart-count{
			background:#f6f6f6;
			color:#ea6011;
			min-width:80rpx;
			text-align:center;
		}
		.reduce{
			width:100rpx;
			text-align:center;
		}
	}
</style>
